package com.zyf.recruit.controller;

import com.zyf.recruit.pojo.Recruit;
import com.zyf.recruit.service.impl.RecruitServiceImpl;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class RecruitController {
    @Autowired
    RecruitServiceImpl recruitService;

    //    需求分析：查询状态为state并以创建日期降序排序，查询前n条记录
    @RequestMapping(value = "/search/recommend", method = RequestMethod.GET)
    public Result recommend(@RequestParam String state) {
        //查询TOP4
        List<Recruit> list = recruitService.findTopNByStateOrderByCreateTimeDesc(4, state);
        return new Result(true, StatusCode.OK, "查询成功", list);
    }
}
